package com.effectiv.gooruda.rest.api.controller.facebook;


import org.springframework.social.facebook.api.Comment;
import org.springframework.social.facebook.api.Facebook;
import org.springframework.social.facebook.api.PagedList;
import org.springframework.social.facebook.api.PagingParameters;
import org.springframework.social.facebook.api.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/api/facebook/commentoperations")
public class CommentOperationsController{

	@RequestMapping(value = "/addcomment/{objectId}", method = RequestMethod.POST)
	public @ResponseBody String addComment(String objectId, String message, Facebook facebook) {
		return facebook.commentOperations().addComment(objectId, message);
	}

	@RequestMapping(value = "/deletecomment/{commentId}", method = RequestMethod.POST)
	public void deleteComment(String commentId, Facebook facebook) {
		facebook.commentOperations().deleteComment(commentId);

	}

	@RequestMapping(value = "/getcomment/{commentId}", method = RequestMethod.GET)
	public @ResponseBody Comment getComment(String commentId, Facebook facebook) {
		return facebook.commentOperations().getComment(commentId);
	}

	

	@RequestMapping(value = "/getcomments/{objectId}", method = RequestMethod.GET)
	public @ResponseBody PagedList<Comment> getComments(String objectId, PagingParameters pagedListParameters, Facebook facebook) {
		return facebook.commentOperations().getComments(objectId,pagedListParameters);
	}

	@RequestMapping(value = "/getcomments/{objectId}/{offset}/{limit}", method = RequestMethod.GET)
	@Deprecated
	public @ResponseBody PagedList<Comment> getComments(String objectId, int offset, int limit, Facebook facebook) {
		return facebook.commentOperations().getComments(objectId, offset, limit);
	}

	@RequestMapping(value = "/getLikes/{objectId}", method = RequestMethod.GET)
	public @ResponseBody PagedList<Reference> getLikes(String objectId, Facebook facebook) {
		return facebook.commentOperations().getLikes(objectId);
	}

}
